package com.service.hibernate.pojos.ServicesUses;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.service.hibernate.pojos.Services;
import com.service.hibernate.pojos.Stocks;

@SuppressWarnings("serial")
@Embeddable
public class ServicesUsesId implements Serializable {

	private Services service;
	private Stocks stock;
	
	@ManyToOne
	@JoinColumn(name="service_id")
	public Services getService() {
		return service;
	}
	public void setService(Services service) {
		this.service = service;
	}
	
	@ManyToOne
	@JoinColumn(name="item_id")
	public Stocks getStock() {
		return stock;
	}
	public void setStock(Stocks stock) {
		this.stock = stock;
	}
	
	public boolean equals(Object o){
		if(this==o)
			return true;
		if(o==null||getClass()!=o.getClass())
			return false;
		
		ServicesUsesId that =(ServicesUsesId)o;
		
		if(service!=null ? !service.equals(that.service): that.service!=null)
			return false;
		if(stock!=null ? !stock.equals(that.stock): that.stock!=null)
			return false;
		
		return true;
	}
	
	public int hashCode(){
		int result;
		result=(stock!=null? stock.hashCode():0);
		result=31*result+(service!=null?service.hashCode():0);
		return result;
	}
}
